<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>

<form:form commandName="task" cssClass="form-horizontal" role="form" onsubmit="return false;">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="taskName">任务名称:</label>
        <div class="col-sm-4">
            <input type="text" name="taskName" id="taskName" placeholder="任务名称" readonly="readonly"
                   value="${task.taskName}" class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="projectName">项目名称:</label>
        <div class="col-sm-4">
            <input type="text" name="projectName" id="projectName" placeholder="项目名称" readonly="readonly"
                   value="${task.projectName}" class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="taskContent">任务内容:</label>
        <div class="col-sm-10">
            <textarea rows="4" id="taskContent" name="taskContent" readonly="readonly"
                      placeholder="任务内容" class="form-control ">${task.taskContent}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="nodeResult">当前节点情况:</label>
        <div class="col-sm-4">
            <input type="text" name="nodeResult" id="nodeResult" readonly="readonly"
                   class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="respResult_">责任单位办结情况:</label>
        <div class="col-sm-4">
            <input type="text" name="respResult_" id="respResult_" readonly="readonly"
                   class="form-control ">
        </div>
    </div>
    <hr width="100%;height:2px;">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="supervision-Result_1">*督查组认定结果:</label>
        <div class="col-sm-4">
            <input type="text" name="supervision-Result_1" id="supervision-Result_1" readonly="readonly"
                   class="form-control ">
        </div>

        <label class="col-sm-2 control-label no-padding-right" for="supervision-Result">*督查组确认:</label>
        <div class="col-sm-4">
            <select name="supervisionResult" class="form-control " style="width: 100%"
                    id="supervision-Result" required>
                <option value="0">未办结</option>
                <option value="1">已办结</option>
            </select>

        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">相关附件下载:</label>
        <div class="col-sm-3">
            <button class="btn btn-sm btn-primary downloadFile" data-id="${nodeFile}"
                    style="width: 100%;">
                下载附件
            </button>
        </div>
    </div>

    <%--<div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">*佐证材料:</label>
        <input class="col-sm-4" type="file" id="fileupload" name="files" />
        <button class="col-sm-4 btn btn-large btn-primary" id="btn-upload">上传</button>
    </div>--%>

    <%--下载--%>
    <input type="text" name="taxproof" id="taxproof_proof" hidden>
    <form:hidden path="sysId"/>
</form:form>
<hr width="100%;height:2px;">
<div class="row" style="margin-left: 2px;">
    * 以上按住如此标志：<img src="/assets/web/img/zzc.png" alt="提示"/>可拖动调整相应输入框大小
</div>
<script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>
<script type="text/javascript">

    /**
     * 下载
     */
    $(".downloadFile").click(function () {
        var id = $(this).data("id");
        if(isEmpty(id)){
            alert("没有附件提供下载！");
        }else{
            var url = "/upLoad/downloadFile/" + id;
            window.open(url);
        }

    });

    // $(".downloadFile").each(function(){
    //     if(isEmpty($(this).data("id"))){
    //         $(this).attr("style","display:none;");
    //     }
    // });

    /**
     * 上传材料
     */
    $("#btn-upload").click(function () {
        var fileval = $("#fileupload").val();
        if (fileval == null || fileval == "") {
            alert("未选择任何文件");
            return;
        }

        $(".shade").fadeIn(100);
        $(".warning").fadeIn(100);
        $('.la-square-jelly-box').show();
        showShade();
        //警告框自定义内容
        $('.warning>.title>em').html('加载中……');
        $.ajaxFileUpload({
            type: "post",
            fileElementId: "fileupload",
            secureuri: false,
            dataType: 'text',
            url: "/communal/uploadBatch",
            // data:fileinfo,
            async: false,
            success: function (data) {
                var data = JSON.parse(data);
                console.log(data);
                var val = data.data.sysid;
                console.log(val);
                $("#taxproof_proof").attr("value", val);
                if (data.code === "200") {
                    $('.warning>.title>em').html('上传成功');
                } else {
                    $('.warning>.title>em').html('上传失败');
                }
            },
            error: function (data) {
                alert("佐证材料上传失败 ！！请联系管理员");
            }
        });
    });


    jQuery(function ($) {
        $('.date-picker').datepicker({
            inline: true,
            format: "yyyymmdd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        }).next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

        var nodeStatus = '${nodeStatus}';
        if (nodeStatus == "1") {
            //节点已完成
            $('#nodeResult').val("督查节点:已完成");
        } else {
            //节点未完成
            $('#nodeResult').val("督查节点:未完成");
            $("#supervision-Result").prepend("<option value='0' selected>任务节点未完成不可选择</option>")
            $('#supervision-Result').attr("disabled", "disabled").css("background-color", "#EEEEEE;");
        }

        var respResult = '${task.respResult}';
        console.log(respResult)
        if (respResult == "1") {
            //节点已完成
            $("#respResult_").val("责任单位已确认完成");
        } else {
            //节点未完成
            $("#respResult_").val("责任单位未确认完成");
            $("#supervision-Result").attr("disabled", "disabled").css("background-color", "#EEEEEE;");
        }

        var supervisionResult = '${task.supervisionResult}';
        if (supervisionResult == "1") {
            $("#supervision-Result").prepend("<option value='1' selected>已选完成</option>");
            $("#supervision-Result_1").val("已完成");
        } else {
            if (nodeStatus == "1") {
                $("#supervision-Result").prepend("<option value='0' selected>暂未确认</option>");
            }
            $("#supervision-Result_1").val("未完成");
        }
    });

</script>